﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>html encode</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="./style/bootstrap.min.css" type="text/css" />
    <script src="./scripts/jquery.slim.min.js"></script>
    <style type="text/css">
        .box{width:calc(100% - 40px);margin: auto;}
    </style>
</head>
<body>
    <div class="box">
        <div style="padding-top:2vh"><textarea class="form-control" id="code" rows="10" placeholder="请输入内容" style="height:80vh"></textarea></div>
        <div class="rows" style="padding-top:10px;">
            <button class="btn btn-success" id="replace">运行</button>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            !(function () {
                function runCode() {
                    var winname = window.open('', "_blank", '');
                    winname.document.open('text/html', 'replace');
                    winname.opener = null;//防止代码对论谈页面修改
                    winname.document.write($('#code').val().replace('""','"'));
                    winname.document.title="document";
                    winname.document.close();
                }
                $('#replace').on('click', function () {
                    if ($('#code').val() == '') return
                    $('#code').val($('#code').val().replace(/""/gi, '"'));
                    runCode();
                })
            })();
        });

    </script>
</body>
</html>